package com.netease.qa.biz.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @author zoudongdong
 * @date 2018/3/8
 */
public class CodeMachine {
    public static String genUserId() {
        StringBuilder sb = new StringBuilder();
        sb.append("Lego");
        sb.append(getDate());
        sb.append(getRandomNum(3));
        return sb.toString();
    }

    private static String getDate() {
        Date cal = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.format(cal);
    }

    private static String getRandomNum(int number) {
        Random ran = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < number; i++) {
            sb.append(ran.nextInt(10));
        }
        return sb.toString();
    }
}
